
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
%\usepackage{ae,aeguill,aecompl}
%\usepackage[T1]{fontenc}
\usepackage{a4wide}
%\usepackage[frenchb]{babel}
%\usepackage{fullpage}
\usepackage[pdftex]{graphicx}
\usepackage{graphicx}
%\pagestyle{empty}

\newcommand\vi{v_i}
\newcommand\vf{v_f}
\newcommand\totaltime{t_{total}}
\newcommand\afixed{a_{fixed}}
\newcommand\amax{a_{max}}
\newcommand\steps{s_{360}}
\newcommand\ssharp{\mathit{s_\#}}

\begin{document}

\section{General equations}

We present various equations for speed $v$, acceleration $a$ and total time $\totaltime$ for accelerating and decelerating a generic motor. $\vi$ and $\vf$will denote respectively the initial and the final speeds of the acceleration/deceleration ramp. We will consider two cases: either a fixed total acceleration/deceleration time denoted $\totaltime$, independent of $\vi$ and $\vf$, or a fixed acceleration rate $\afixed$, yielding in a variable total acceleration/deceleration time. 

We also focus in the case of a stepper motor: $\steps$ denotes the number of steps (or microsteps) per revolution. $s$ will denote the current step number, and $p$ will denote the period of the current step. The period $p$ as a function of $v$ is given by: $p(t) = 360 / (\steps \times v(t))$ if $v$ is expressed in degrees per second. The current step number $s$ is given by integrating the speed function over the time and retaining its integer part: $s(t) = \lfloor (\steps/360) \times \int_0^t v(u)du \rfloor$.

\subsection{Linear speed ramping}
\begin{enumerate}
\item Normalized form: $v(t) = t$
\item Fixed total acceleration time: $v(t)=\vi + ((\vf-\vi)\times(t/\totaltime))$ with:
\begin{itemize}
  \item a constant acceleration of $a=(\vf-\vi)/\totaltime$
  \item $s(t) = \lfloor (\steps/360) \times (\vi \times t + ((\vf-\vi) \times (t^2/(2\times\totaltime)))) \rfloor$
  \item $p(t) = (360/\steps) \times 1 / (\vi + ((\vf-\vi)\times(t/\totaltime)))$
\end{itemize}
\item Fixed acceleration rate: $v(t)=\vi + (\afixed \times t)$ with 
\begin{itemize}
  \item a totaltime of $\totaltime=(\vf-\vi)/\afixed$
  \item $s(t) = \lfloor (\steps/360) \times (\vi \times t + (\afixed \times (t^2/2))) \rfloor$
  \item $p(t) = (360/\steps) \times 1 / (\vi + (\afixed \times t))$
\end{itemize}
\end{enumerate}

Figure~\ref{speedlinear} presents the diagrams for speed, step number and period in the case of accelerating from a speed of $180^{\circ}/s$ (0.5 rps) to a speed of $1440^{\circ}/s$ (4 rps). Diagrams in the left column concern the case of a fixed total acceleration time of 2.0s, diagrams in the rigth column concern a fixed acceleration rate of $360^{\circ}/s^2$.

\subsection{Sigmoïd (S-shaped) speed ramping}
We define a constant value $\ssharp$ which represents the sharpness of the sigmoïd curve. As the acceleration is not constant, we will use a maximum allowed acceleration value $\amax$ in place of the former $\afixed$ constant value of the fixed rate case.
\begin{enumerate}
\item Normalized speed: $v(t) =  1/(1 + e{-((\ssharp \times t) - (\ssharp / 2))})$ 
\item Normalized acceleration: $a(t) =  (\ssharp \times e^{-((\ssharp \times t) - (\ssharp / 2))}) / (1 + e^{-((\ssharp \times t) - (\ssharp / 2))}))^2$ 
\item Fixed total acceleration time: $v(t)=\vi + ((\vf-\vi) \times 1/(1 + e^{-((\ssharp \times t) / \totaltime - (\ssharp / 2))}))$ with:
\begin{itemize}
  \item a maximum acceleration of $\amax=((\vf-\vi) \times \ssharp) / (4 \times \totaltime)$
  \item $s(t) = \lfloor (\steps/360) \times (\vi \times t + ((\vf-\vi) \times (\totaltime / \ssharp) \times \ln(1 + e^{-((\ssharp \times t)  / \totaltime  - (\ssharp / 2))}))) \rfloor$
  \item $p(t) = (360/\steps) \times (1 / (\vi + ((\vf-\vi) \times 1/(1 + e^{-((\ssharp \times t) / \totaltime - (\ssharp / 2))}))))$
\end{itemize}
\item Maximum acceleration rate: $v(t)=\vi + ((\vf-\vi) \times 1/(1 + e^{-((4 \times \amax \times t) / (vf-vi) - (\ssharp / 2))}))$ with 
\begin{itemize}
  \item a totaltime of $\totaltime= (\ssharp \ times (\vf-\vi)) / (4 \times \amax)$
  \item $s(t) = \lfloor (\steps/360) \times (\vi \times t + ((\vf-\vi) \times ((\vf - \vi) / (4 \times \amax)) \times \ln(1 + e^{-((4 \times \amax \times t) / (vf-vi) - (\ssharp / 2))})))\rfloor$
  \item $p(t) = (360/\steps) \times (1 + (\vi + ((\vf-\vi) \times 1/(1 + e^{-((4 \times \amax \times t) / (vf-vi) - (\ssharp / 2))})) )$
\end{itemize}
\end{enumerate}

Figure~\ref{speedsshaped} presents the diagrams for speed, step number and period in the case of accelerating from a speed of $180^{\circ}/s$ (0.5 rps) to a speed of $1440^{\circ}/s$ (4 rps). Diagrams in the left column concern the case of a fixed total acceleration time of 2.0s, diagrams in the rigth column concern a maximum acceleration rate of $360^{\circ}/s^2$. The sharpness value $\ssharp$ used in those diagrams is 10.

\newpage
\begin{figure}
\includegraphics[width=0.95\textwidth,keepaspectratio]{figs/speedlinear.png}
\caption{Speed, step number and period diagrams for linear ramping. First row presents the normalized speed and acceleration diagrams. Last three rows present respectively speed, step number and period diagrams for an acceleration ramp from 0.5 rps to 4 rps. Left column concerns a fixed acceleration time of 2.0s, right column concerns a fixed acceleration rate of 1 rps per second\label{speedlinear}}
\end{figure}

\newpage
\begin{figure}
\includegraphics[width=0.95\textwidth,keepaspectratio]{figs/speedsshaped.png}
\caption{Speed, step number and period diagrams for sigmoid ramping. First row presents the normalized speed and acceleration diagrams for a sharpness value $\ssharp=10$. Last three rows present respectively speed, step number and period diagrams for an acceleration ramp from 0.5 rps to 4 rps. Left column concerns a fixed acceleration time of 2.0s, right column concerns a maximum acceleration rate of 1 rps per second\label{speedsshaped}}
\end{figure}

\end{document}
